package day0;
import java.util.Scanner;

import org.junit.Test;

public class Day2 {
	
	//soeasy版商品收银系统
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入单价:");
		double danjia = scanner.nextDouble();// 单价

		System.out.println("请输入商品数量:");
		double num = scanner.nextDouble();// 数量

		double yingshouje = Zongjia(danjia, num);// 应收金额
		if (yingshouje >= 500) {
			yingshouje = yingshouje * 0.8;
			System.out.println("商品原总价为"+yingshouje/0.8+"   超过500元  ,  打八折为" + yingshouje);
		} else {
			System.out.println("共计总价为:" + yingshouje);
		}
		System.out.println("您的实付金额为:");
		double jine = scanner.nextDouble();// 金额
		
		//钱不够的情况
		while(jine < yingshouje){
				System.out.println("您钱不够,请重新付款");
				jine = scanner.nextDouble();// 金额
		}
		
		//设置
		double zhaoling = Zhaoling(yingshouje, jine);// 找零
		if(zhaoling == 0) {		
			System.out.println("钱正正好好!");
		}else {
			System.out.println("应找钱数量为:" + zhaoling);
		}
	}
	
	public static  double Zongjia(double danjia, double num) {
		double yingshouje = danjia * num;
		return yingshouje;
	}

	public static  double Zhaoling(double yingshouje, double jine) {
		double zhaoling = jine - yingshouje;
		return zhaoling;

	}
	
	@Test
	public void close() {
		System.out.println("关了个门");
	}
}
	

